<HTML><HEAD><TITLE>frandom(-F)</TITLE>
</HEAD><BODY>[ <A HREF="index.html">Arithmetic</A> | <A HREF="../../index.html">Reference Manual</A> | <A HREF="../../fullindex.html">Alphabetic Index</A> ]
<H1>frandom(-F)</H1>
Generates a random floating-point number F in the range &lt;0, 1&gt;.


<DL>
<DT><EM>F</EM></DT>
<DD>Floating-point number or variable.
</DD>
</DL>
<H2>Description</H2>
   frandom/1 unifies F with a random floating-point number between 0 and 1.
   The code is taken from random2.c by John Burton, available from the net.
   Part of original comment:

<P>
<PRE>
 *
 * PMMMLCG - Prime Modulus M Multiplicative Linear Congruential Generator   *
 *  Modified version of the Random number generator proposed by             *
 *  Park &amp; Miller in "Random Number Generators: Good Ones Are Hard to Find" *
 *  CACM October 1988, Vol 31, No. 10                                       *
 *   - Modifications proposed by Park to provide better statistical         *
 *     properties (i.e. more "random" - less correlation between sets of    *
 *     generated numbers                                                    *
 *   - generator is of the form                                             *
 *         x = ( x * A) % M                                                 *
 *   - Choice of A &amp; M can radically modify the properties of the generator *
 *     the current values were chosen after followup work to the original   *
 *     paper mentioned above.                                               *
 *   - The generator has a period of 0x3fffffff with numbers generated in   *
 *     the range of 0 &lt; x &lt; M                                               *
 *   - The generator can run on any machine with a 32-bit integer, without  *
 *     overflow.                                                            *
</PRE>

<H3>Modes and Determinism</H3><UL>
<LI>frandom(-) is det
</UL>
<H3>Exceptions</H3>
<DL>
<DT><EM>(5) type error </EM>
<DD>F is instantiated, but not to a floating-point number.
</DL>
<H2>Examples</H2>
<PRE>
Success:
      [eclipse]: frandom(F1), frandom(F2).
      F1 = 0.900086582
      F2 = 0.0795856342
      yes.

      [eclipse]: seed(1), frandom(F).
      F = 2.2477936e-05
      yes.
      [eclipse]: seed(1), frandom(F).
      F = 2.2477936e-05
      yes.

Fail:
      frandom(123.45).

Error:
      frandom(1234).          (Error 5).



</PRE>
<H2>See Also</H2>
<A HREF="../../kernel/arithmetic/seed-1.html">seed / 1</A>, <A HREF="../../kernel/arithmetic/random-1.html">random / 1</A>
</BODY></HTML>
